class_name Card

extends Resource

enum Type{ATTACK, SKILL, POWER}
enum  Target{SELF, SINGLE_ENEMY, ALL_ENEMY, EVERYONE}

@export_group("Card Attributes")
@export var id: String
@export var type: Type
@export var target: Target
@export var cost: int

@export_group("Card Visuals")
@export var icon: Texture
@export_multiline var tooltip_text: String

func is_singel_enemy() -> bool:
	return target == Target.SINGLE_ENEMY
	
func _get_targets(targets: Array[Node]) -> Array[Node]:
	if not targets:
		return []
	var tree := targets[0].get_tree()
	match target:
		Target.SELF:
			#重点:这里返回的应该是类的名称，此处是Player
			return tree.get_nodes_in_group("player")
		Target.ALL_ENEMY:
			return tree.get_nodes_in_group("enemies")
		Target.EVERYONE:
			return tree.get_nodes_in_group("player") + tree.get_nodes_in_group("enemies")
		_:
			return []

func play(targets: Array[Node], char_stats: CharacterStats) -> void:
	print("targets", targets)
	Events.card_played.emit(self)
	char_stats.mana -= cost
	if is_singel_enemy():
		apply_effects(targets)
	else:
		apply_effects(_get_targets(targets))

func apply_effects(_targets: Array[Node]) -> void:
	pass













